package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CusorderData2;
import com.ruoyi.system.service.ICusorderData2Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 客户订单处理Controller
 * 
 * @author cyx
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/data2")
public class CusorderData2Controller extends BaseController
{
    @Autowired
    private ICusorderData2Service cusorderData2Service;

    /**
     * 查询客户订单处理列表
     */
    @PreAuthorize("@ss.hasPermi('system:data2:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusorderData2 cusorderData2)
    {
        startPage();
        List<CusorderData2> list = cusorderData2Service.selectCusorderData2List(cusorderData2);
        return getDataTable(list);
    }

    /**
     * 导出客户订单处理列表
     */
    @PreAuthorize("@ss.hasPermi('system:data2:export')")
    @Log(title = "客户订单处理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CusorderData2 cusorderData2)
    {
        List<CusorderData2> list = cusorderData2Service.selectCusorderData2List(cusorderData2);
        ExcelUtil<CusorderData2> util = new ExcelUtil<CusorderData2>(CusorderData2.class);
        util.exportExcel(response, list, "客户订单处理数据");
    }

    /**
     * 获取客户订单处理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:data2:query')")
    @GetMapping(value = "/{data2Id}")
    public AjaxResult getInfo(@PathVariable("data2Id") Long data2Id)
    {
        return success(cusorderData2Service.selectCusorderData2ByData2Id(data2Id));
    }

    /**
     * 新增客户订单处理
     */
    @PreAuthorize("@ss.hasPermi('system:data2:add')")
    @Log(title = "客户订单处理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusorderData2 cusorderData2)
    {
        return toAjax(cusorderData2Service.insertCusorderData2(cusorderData2));
    }

    /**
     * 修改客户订单处理
     */
    @PreAuthorize("@ss.hasPermi('system:data2:edit')")
    @Log(title = "客户订单处理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusorderData2 cusorderData2)
    {
        return toAjax(cusorderData2Service.updateCusorderData2(cusorderData2));
    }

    /**
     * 删除客户订单处理
     */
    @PreAuthorize("@ss.hasPermi('system:data2:remove')")
    @Log(title = "客户订单处理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{data2Ids}")
    public AjaxResult remove(@PathVariable Long[] data2Ids)
    {
        return toAjax(cusorderData2Service.deleteCusorderData2ByData2Ids(data2Ids));
    }
}
